package com.herench.bs.handler;

import com.herench.bs.agent.IOutpatientClinicAgent;
import com.herench.bs.annotation.Handler;
import com.herench.bs.support.AbstractMessageHandler;
import com.herench.bs.support.RequestMessage;
import com.herench.bs.support.ResponseMessage;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * cleverClinic
 * com.herench.bs.handler
 *
 * @author wangwenkai
 * @date 2017/12/7/15:22
 * 获取未支付订单明细
 */
@Component
@Handler(code = "100905" ,name="查询未完成交易订单")
public class LoadUnpaidOrdersHandler extends AbstractMessageHandler {
    @Override
    protected ResponseMessage innerHandler(RequestMessage requestMessage) throws Exception {
        ResponseMessage responseMessage = new ResponseMessage(requestMessage.getId());
        String channelCode = requestMessage.getArgsPropertyStringValue("sysCode");
        String user = requestMessage.getArgsPropertyStringValue("user");
        String source = requestMessage.getArgsPropertyStringValue("source");
        String orderType = requestMessage.getArgsPropertyStringValue("orderType");
        String idCard = requestMessage.getArgsPropertyStringValue("idCard");
        IOutpatientClinicAgent outpatientClinicAgent = getCleverClinicContext().getApplicationContext().getBean(IOutpatientClinicAgent.class);
        String hospitalCode = getCleverClinicContext().getHospitalCodeByChannelCode(channelCode);
        Map<String, Object> res = outpatientClinicAgent.loadUnpaidOrders(channelCode, hospitalCode, idCard, source, user, orderType);
        responseMessage.setData(res);
        getPropertiesFromInvokerResultMap(responseMessage, res);
        return responseMessage;
    }
}
